<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加学生</title>
<link rel="stylesheet" href="./layui/css/layui.css">
<style type="text/css">
	form {
		margin-top:45px;
		margin-left:10px;
	}
</style>
</head>
<body>
	<form id="myForm" class="layui-form layui-form-pane" action="AddStudent.do" method="post">
		<div class="layui-form-item">
			<label class="layui-form-label">学号</label>
			<div class="layui-input-inline">
				<input type="text" name="studentid" id="studentid" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">课程号</label>
			<div class="layui-input-inline">
				<input type="text" name="courseid" id="courseid" autocomplete="off" class="layui-input">
			</div>
		</div>
	  	<div class="layui-form-item">
			<div class="layui-inline">
	      		<button class="layui-btn" lay-submit="" lay-filter="demo">提交</button>
				<button class="layui-btn" lay-submit="" lay-filter="demo" type="reset">清空</button>
	    	</div>
	  	</div>
	</form>
          
<script src="./layui/layui.js" charset="utf-8"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
	layui.use(['form'],function(){
		var form = layui.form;
		
		form.on('submit(demo)',function(data){
			var username = $('#username').val();
			var role = $('#role').val();
			var password = $('#password').val();
			layer.alert(JSON.stringify(data.field),{
				title:"添加信息"
			})
			$.ajax({
				type:"POST"
				,url:"AddStudent.do"
				,data: {
					studentid:studentid,
					courseid:courseid
				}
				,success:function(result) {
					console.log(result);
					layer.msg("添加成功")
					setTimeout( function(){
                    	var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }, 1 * 1000 );
				},
				error:function(){
					layer.msg("添加失败");
				}
			});
			return false;
		});
	});
</script>
</body>
</html>